﻿using NinjaToolbox.SubComponentModule.Example;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.BattleSystem
{
    public class EventCallback : MonoBehaviour
    {
        void Start()
        {
            var battleObject = GetComponent<BattleObject>();

            var damageSubComponent = battleObject.BattleSubComponentContainer.GetSubComponent<DamageSubComponent>();

            damageSubComponent.OnHPChangedCallback += onHPChangedCallback;
            damageSubComponent.OnAttackCompletedCallback += onAttackCompletedCallback;
            damageSubComponent.OnResurrectionCallback += onResurrectionCallback;
            damageSubComponent.OnDiedCallback += onDiedCallback;
            damageSubComponent.OnHurtCallback += onHurtCallback;
            damageSubComponent.OnKilledCallback += onKilledCallback;
        }

        [ContextMenu("Resurrection")]
        void Resurrection()
        {
            var battleObject = GetComponent<BattleObject>();
            var damageSubComponent = battleObject.BattleSubComponentContainer.GetSubComponent<DamageSubComponent>();
            damageSubComponent.Resurrection(100);
        }

        void onAttackCompletedCallback(BattleObject self, BattleObject hurter)
        {
            Debug.Log("[onAttackCompletedCallback] self: " + self + " hurter: " + hurter);
        }

        void onDiedCallback(BattleObject self)
        {
            Debug.Log("[onDiedCallback] self: " + self);
        }

        void onHurtCallback(BattleObject self, BattleObject attacker, int damage)
        {
            Debug.Log("[onHurtCallback] self: " + self + " attacker: " + attacker + " damage: " + damage);
        }

        void onKilledCallback(BattleObject self, BattleObject deceased)
        {
            Debug.Log("[onKilledCallback] self: " + self + " deceased: " + deceased);
        }

        void onResurrectionCallback(BattleObject self)
        {
            Debug.Log("[onResurrectionCallback] self: " + self);
        }

        void onHPChangedCallback(BattleObject self, int oldHP, int newHP)
        {
            Debug.Log("[onHPChangedCallback] self: " + self + " oldHP: " + oldHP + " newHP: " + newHP);
        }
    }
}
